#include<stdio.h>

int My_Compere(const void* p1, const void* p2)
{
	return (*(char*)p1- *(char*)p2);
}
void My_Swap(void *p1,void* p2,size_t count)
{
	for (size_t i = 0; i < count; i++)
	{
		char mid = *((char*)p1 + i);
		*((char*)p1 + i) = *((char*)p2 + i);
		*((char*)p2 + i) = mid;
	}
	return;
}
void My_Qsort(void* base, size_t sz, size_t count, int (*p)(const void* p1, const void* p2))
{
	char* start = (char*)base;
	for (size_t i = 0; i < sz - 1; i++)
	{
		for (size_t j = 0; j < sz - 1 - i; j++)
		{
			if (p(start+count*j, start + count*(j+1)))
			{
				My_Swap((char*)start + count * j, (char*)start + count * (j + 1),count);
			}
		}
	}
	return;
}
void My_Print(char arr[], int sz)
{
	for (int i = 0; i < sz; i++)
	{
		printf("%c ", arr[i]);
	}
	return;
}
int main()
{
	char arr[] = {'a','b','c','d','e','f','g','h','i'};
	int sz = sizeof(arr) / sizeof(arr[0]);
	My_Qsort(arr,sz,sizeof(char),My_Compere);
	My_Print(arr,sz);
	return 0;
}